// 所有的id列表,下标是对应序号
this.LIVE_ID = [258, 242, 217, 268, 263, 252, 251, 247, 259, 255, 248, 250, 238, 230, 218, 226, 270, 249, 224, 232, 257, 222, 267, 227, 229, 271];
// 所有的直播点击位置列表,下标是对应序号，1：右，2：左
this.LIVE_STYLE = [1, 2, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 2, 1, 2, 1, 1, 2];
// 活动第一天日期，不能跨月
this.FIRST_DAY = 26;
var date = new Date();
var today = (date.getDate() - FIRST_DAY) >= 0 ? (date.getDate() - FIRST_DAY) : 0;
console.log(today);

// 显示的直播以及顺序
var liveGroup = [
    [0, 1, 2, 3, 4, 5],
    [6, 7, 8, 9, 10, 11, 12],
    [13, 14, 15, 16, 17, 18, 19],
    [20, 21, 22, 23, 24, 25]
];
var todayLength = liveGroup[today].length;
// var liveindex = liveGroup[today];
liveGroup = channgeArr(liveGroup, today);
var liveindex = liveGroup.join(',').split(',').map(function (a) {return Number(a)});


$('.day-' + today).show();

(function() {
    var _htmlLive = [];
    for (_i in liveindex) {
        _htmlLive.push(
            '<div class="box-item item-style-' + LIVE_STYLE[liveindex[_i]] + '" index="' + liveindex[_i] + '">' +
            '<img class="img-live-item" src="images/live-' + (liveindex[_i] + 1) + '.jpg" alt="">' +
            '<div class="box-click" value="' + liveindex[_i] + '"></div>' +
            '</div>'
        )
        if(_i == (todayLength-1)){
          _htmlLive.push('<img src="images/live_next.png" alt="" class="day-title">')
        }
    }
    $('.container').html(_htmlLive.join('\n'))
})();



if (isLalocal=='1') {
    $('.box-item').on('click', '.box-click', function() {
        var _index = $(this).attr('value');
        console.log('app:' + window.LIVE_ID[_index]);
        window.location.href = 'lalocal://app?{"targetType": "15","targetId": "' + window.LIVE_ID[_index] + '"}';
    });
}
else if (isLalocal=='2') {

}
 else {
    $('.box-item').on('click', '.box-click', function() {
        var _index = $(this).attr('value');
        console.log(window.LIVE_ID[_index]);
        window.location.href = 'https://h5.lalocal.cn/channel?id=' + window.LIVE_ID[_index];
    });
}

/**
 * [0,1,2,3,4] => [2,3,4,0,1]
 * @method channgeArr
 * @param  {[type]} list 需要排序的数组
 * @param  {[type]} index 开始的下标
 * @return {array} [返回排序后的新数组]
 */
function channgeArr(list, index) {
    var _list = list;
    var _i = index;
    return _list.slice(index, _list.length).concat(_list.slice(0, _i));
}

$('.lixiang-test').on('click', '.box-click', function() {
    window.location.href = 'lalocal://app?{"targetType": "20","targetId": "1589"}';
});
